<?php

namespace App\Services;


use App\Models\SmsLog;

class AliSmsService
{

    public static function validate($code, $mobile)
    {


        $is_existence = SmsLog::where('mobile', $mobile)
            ->where('code', $code)
            ->where('checked', 0)
            ->where('status', 1)
            ->first();
        if ($is_existence) {
            $is_existence->checked = 1;
            $is_existence->save();

            return true;
        }

        return false;
    }

    public static function isValid($code, $mobile)
    {


        $is_existence = SmsLog::where('mobile', $mobile)
            ->where('code', $code)
            ->where('checked', 0)
            ->where('status', 1)
            ->first();
        if ($is_existence) {
            return true;
        }

        return false;
    }
    public static function is_mobile($mobile)
    {
        return preg_match('/^1[3456789]\d{9}$/', $mobile);
    }

}
